
$(function () {
    $("#jqGrid").jqGrid({
        url: '/platform/oem/loanAccessList',
        datatype: "json",
        colModel: [
            { label: 'id', name: 'accessId', index: 'accessId', width: 50 ,key:true,hidden:true},
            { label: '用户', name: 'username', index: 'username'},
            { label: '所在城市', name: 'city', index: 'city'},
            { label: '单位名称', name: 'companyName', index: 'companyName'},
            { label: '现住地址', name: 'phone', index: 'phone'},
            { label: '状态', name: 'status', index: 'status',formatter: function(value, options, row){
                if (value == 0)
                    return '<span class="label label-warning">待处理</span>';
                if (value == 1)
                    return '<span class="label label-primary">已处理</span>';
                return '-';
            }},
            { label: '申请时间', name: 'createDate', index: 'createDate'}
        ],
		viewrecords: true,
        height: 385,
        rowNum: 10,
		rowList : [10,30,50],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "result.list",
            page: "result.currPage",
            total: "result.totalPage",
            records: "result.totalCount"
        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条\
        	$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
        }
    });

});

Vue.prototype.brs = function (value) {
    return value == null?null:value.replace(/\##/g,"<br>");
};

var vm = new Vue({
	el:'#rrapp',
	data:{
		showList: true,
		showInfo:false,
		title: null,
		isUpdate:false,
		access: {},
	},
	methods: {
		query: function () {
			vm.reload();
		},
        info:function () {
		    vm.showList = false;
            var id = getSelectedRow();
            if (id == null)
                return;
            $.getJSON("/platform/oem/loanAccessInfo/"+id,null,function (r) {
                if (r.code == 200){
                    vm.access = r.result;
                    console.log(r);
                }else
                    alert(r.message);
            });
        },
        handel:function () {
            $.getJSON("/platform/oem/handelLoanAccess/"+vm.access.accessId,null,function (r) {
                if (r.code == 200){
                    alert("处理成功");
                    vm.reload();
                }else
                    alert(r.message);
            });
        },
        reload: function (event) {
            vm.showList = true;
            vm.showInfo = false;
			$("#jqGrid").jqGrid('setGridParam',{
                page:1
            }).trigger("reloadGrid");
            vm.isUpdate = false;
		}
	}
});